package com.woniuxy.hystrix;

import com.woniuxy.api.RemoteProductService;
import com.woniuxy.entity.Product;
import com.woniuxy.entity.ProductDTO;
import com.woniuxy.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FallbackFactoryCommand implements FallbackFactory<RemoteProductService> {
    @Override
    public RemoteProductService create(Throwable cause) {
        return new RemoteProductService() {
            @Override
            public ResponseEntity findOneByPid(Integer pid) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity updateProduct(Product product) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity findAllByNameOrPrice(ProductDTO productDTO) {
                return ResponseEntity.TIMEOUT;
            }
        };
    }
}
